//
//  DYEnv.m
//  test
//
//  Created by Zhuangyh on 16/1/29.
//  Copyright © 2016年 jaga. All rights reserved.
//

#import "DYEnv.h"
#include <UIKit/UIKit.h>

@implementation DYEnv
singleton_implementation(DYEnv)

- (instancetype)init {
    if (self = [super init]){
        [self configLog];
        [self customizeTabBarInterface];
    }
    return self;
}

#pragma -mark private
- (void)configLog {
    //----------------------------------XcodeColors------------------------------------
    //开启使用 XcodeColors
    setenv("XcodeColors", "YES", 0);
    //检测是否开启 XcodeColors
    char *xcode_colors = getenv("XcodeColors");
    if (xcode_colors && (strcmp(xcode_colors, "YES") == 0))
    {
        // XcodeColors is installed and enabled!
        NSLog(@"控制台颜色 开启");
    }else {
        NSLog(@"控制台颜色 开启失败");
    }
    
    //----------------------------------DDLog------------------------------------
    //开启DDLog 颜色
    [[DDTTYLogger sharedInstance] setColorsEnabled:YES];
    [[DDTTYLogger sharedInstance] setForegroundColor:[UIColor blueColor] backgroundColor:nil forFlag:DDLogFlagVerbose];
    
    //配置DDLog
    [DDLog addLogger:[DDTTYLogger sharedInstance]]; // TTY = Xcode console
    [DDLog addLogger:[DDASLLogger sharedInstance]]; // ASL = Apple System Logs
    
    DDFileLogger *fileLogger = [[DDFileLogger alloc] init]; // File Logger
    fileLogger.rollingFrequency = 60 * 60 * 24; // 24 hour rolling
    fileLogger.logFileManager.maximumNumberOfLogFiles = 7;
    [DDLog addLogger:fileLogger];
    
    //tabbar 设置 在下面函数customizeTabBarInterface和TabBarViewCtrlConfig中
    //navibar 设置 在DYNavigationController中
}

- (void)customizeTabBarInterface {
    //图片配置见 TabBarViewCtrlConfig的customizeTabBarForController
    
    // 普通状态下的文字属性
    NSMutableDictionary *normalAttrs = [NSMutableDictionary dictionary];
    normalAttrs[NSForegroundColorAttributeName] = [UIColor grayColor];
    
    // 选中状态下的文字属性
    NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary];
    selectedAttrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor];
    
    // 设置文字属性
    UITabBarItem *tabBar = [UITabBarItem appearance];
    [tabBar setTitleTextAttributes:normalAttrs forState:UIControlStateNormal];
    [tabBar setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected];
    
    // 设置背景图片
//    UITabBar *tabBarAppearance = [UITabBar appearance];
//    [tabBarAppearance setBackgroundImage:[UIImage imageNamed:@"tabbar_background"]];
    
}


@end
